<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    {tpl style}
    <title>{$webname}会员登陆</title>
</head>
<body>
{tpl head}
<div id="main">
    <div class="container-fluid">
        <div class="row white_bg">
            <div class="login_member"><img src="{$skin}img/login_member.png" class="img-responsive" alt="会员登陆"></div>
            <form action="" class="login_form" method="post">
                <div class="input-group input-group-lg mt10 mb10">
                    <div class="input-group-addon"><span class="glyphicon glyphicon-phone"></span></div>
                    <input type="text" name="mobile" id="user" class="form-control" placeholder="请输入用户名" >
                </div>
                <div class="input-group input-group-lg mb10">
                    <div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
                    <input type="password" class="form-control" name="password" id="pass" placeholder="请输入密码" >
                </div>
                <div class="input-group input-group-lg mb10">
                    <div class="input-group-addon"><span class=" glyphicon glyphicon-equalizer"></span></div>
                    <input type="text" class="form-control" name="captcha" id="captcha" placeholder="验证码" >
                    <span class="input-group-addon"><img src="vcode.php" alt="" onclick="this.src='vcode.php?tm=' + Math.random();"  style="cursor:pointer;" /></span>
                </div>
                <button class="btn btn-danger btn-block btn-lg " name="click" type="button" onclick="login()">我要登陆</button>
            </form>
        </div>
    </div>
</div>
{tpl foot}
<div class="footer">
    <p>客服QQ:123456 <a href="http://wpa.qq.com/msgrd?v=3&uin=123456&site=qq&menu=yes">在线客服</a></p>
</div>
<script language="javascript" type="text/javascript">
    function login(){
        var mobile=$("input[name=mobile]").val();
        var re = /^1\d{10}$/
        if (!re.test(mobile)) {
            alerts("请输入正确的手机号码");
            return false;
        }
        var pass=$("input[name=password]").val();
        if(pass.length>20 || pass.length<6){
            alerts('请保持密码长度在6-12位');
            return false;
        }
        var captcha=$("input[name=captcha]").val();
        if(captcha.length!=4){
            alerts("请输入验证码");
            return false;
        }
        $.post('{:url('users/login')}', {mobile: mobile,captcha:captcha,password:pass,cpassword:captcha}, function(data){
            if(data.status>0){
                alerts(data.message);
            }else{
                location.href='{:url('index/index')}';
            }
        }, 'json');
        return false;
    }


    function alerts(msg) {
        alert(msg);
    }
</script>
</body>
</html>
